﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for TaiKhoan
/// </summary>
public class TaiKhoan
{
	public TaiKhoan()
	{		
	}

    private string _tk;

    public string Tk
    {
        get { return _tk; }
        set { _tk = value; }
    }
    private string _mk;

    public string Mk
    {
        get { return _mk; }
        set { _mk = value; }
    }

    private string _mkmoi;

    public string Mkmoi
    {
        get { return _mkmoi; }
        set { _mkmoi = value; }
    }


    public DataTable LoadThongTinTaiKhoan()
    {
        string proName = "website_login";
        DataService ds = new DataService();
        ds.Connect();
        SqlParameter[] parameters = new SqlParameter[2];
        parameters[0] = new SqlParameter("@taikhoan", Tk);
        parameters[1] = new SqlParameter("@matkhau", Mk);
        DataTable table = ds.ExcuteProcedureGetTable(proName, parameters);
        ds.Disconnect();
        return table;
    }

    public DataTable LoadTaiKhoan()
    {
        string proName = "website_info_email";
        DataService ds = new DataService();
        ds.Connect();
        SqlParameter[] parameters = new SqlParameter[1];
        parameters[0] = new SqlParameter("@taikhoan", Tk);       
        DataTable table = ds.ExcuteProcedureGetTable(proName, parameters);
        ds.Disconnect();
        return table;
    }



    public int DoiMatKhau()
    {
        string proName = "tk_DoiMatKhau";
        DataService ds = new DataService();
        ds.Connect();
        //: Tạo câu truy vấn thực hiện thao tác lên cơ sở dữ liệu
        SqlParameter[] parameters = new SqlParameter[3];
        parameters[0] = new SqlParameter("@tk", Tk);
        parameters[1] = new SqlParameter("@mkcu", Mk);
        parameters[2] = new SqlParameter("@mkmoi", Mkmoi);
        int i = ds.ExcuteProcedureWithReturn(proName, parameters);
        ds.Disconnect();
        return i;
    }
}